package cn.bugstack.domain.activity.service.trail.thread;

import cn.bugstack.domain.activity.adapter.repository.IActivityRepository;
import cn.bugstack.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
import cn.bugstack.domain.activity.model.valobj.SCSkuActivityVO;

import java.util.concurrent.Callable;

/**
 * @Author caoyi
 * @description:
 * @Date 2025/7/30 17:53
 */
public class QueryGroupBuyActivityDiscountVOThreadTask implements Callable<GroupBuyActivityDiscountVO> {
    //使用构造器注入 sc+repository
    private final IActivityRepository repository;
    private final String source;
    private final String channel;

    private final String goodsId;

    public QueryGroupBuyActivityDiscountVOThreadTask(IActivityRepository repository, String source, String channel, String goodId) {
        this.repository = repository;
        this.source = source;
        this.channel = channel;
        this.goodsId = goodId;
    }

    @Override
    public GroupBuyActivityDiscountVO call() throws Exception {
        //先查商品表scsku 再通过商品表得到活动id
        SCSkuActivityVO scSkuActivityVO = repository.querySCSkuActivityBySCGoodsId(source, channel, goodsId);
        if(scSkuActivityVO==null) return  null;
        //查询活动配置
        return repository.queryGroupBuyActivityDiscountVO(scSkuActivityVO.getActivityId());
    }
}
